package com.hm.pan.controller;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import com.hm.pan.annotation.CheckLogin;
import com.hm.pan.model.ResultObj;
import com.hm.pan.service.LoginHistoryService;

@RestController
@CheckLogin
public class LoginHistoryController {

	@Resource
	private LoginHistoryService loginHistoryService;

	@PostMapping("findUserHistory")
	public Object findUserHistory(Integer userId, HttpSession session) {
//		User attribute = (User) session.getAttribute("user");
		ResultObj resultObj = new ResultObj();
		System.out.println(loginHistoryService.findUserHistory(userId));
		try {
			resultObj.setData(loginHistoryService.findUserHistory(userId));
			resultObj.setMessage("查询成功");
			resultObj.setStatusCode(200);
			return resultObj;
		} catch (Exception e) {
			resultObj.setMessage("查询失败");
			resultObj.setStatusCode(500);
		}
		return resultObj;
	}
}
